package com.cg.controller;

import com.cg.dto.Result;
import com.cg.dto.ResultUtils;
import com.cg.entity.Info;
import com.cg.service.InfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Info)表控制层
 *
 * @author chengong
 * @since 2024-01-07 14:45:28
 */
@RestController
@RequestMapping("/info")
public class InfoController {
    /**
     * 服务对象
     */
    @Resource
    private InfoService infoService;

    /**
     * 授权
     */
    @PostMapping("/addInfo")
    public Result addInfo(@RequestParam("cardNum") String cardNum){
        return infoService.addInfo(cardNum);
    }


    /**
     * 查询全部授权信息
     */
    @GetMapping("/queryInfoList")
    public Result<List<Info>> queryInfoList(){
        List<Info> infoList = infoService.queryInfoList();
        return ResultUtils.returnDataSuccess(infoList);
    }


    /**
     * 根据授权名称查询授权信息
     */
    @GetMapping("/queryInfo")
    public Result<Info> queryInfo(@RequestParam("infoName") String infoName) {
        return ResultUtils.returnDataSuccess(infoService.queryInfo(infoName));
    }

}

